package com.u3k.mid;

import android.content.Context;
import android.text.TextUtils;
import com.u3k.app.mid.utils.net.HttpClient;
import com.u3k.app.mid.utils.net.Request;
import com.u3k.app.mid.utils.statistics.StatisticsManager;

public class ay {
    public static void a(Context context) {
        try {
            if (c(context)) {
                bb.a(context, "domain_fail", Integer.valueOf(0));
            }
        } catch (Exception e) {
            StatisticsManager.getInstance().logException(ae.a(), e);
        }
    }

    public static void a(Context context, String str) {
        synchronized (ay.class) {
            try {
                LogUtils.a("PingUtils", "changeDomain.domain=" + str);
                String str2 = (String) bb.b(context, "domain", "");
                if (!(TextUtils.isEmpty(str) || TextUtils.equals(str, str2))) {
                    new HttpClient().request(new Request().url(str + "/api/unify/cmn/v1/ping"), new az(context, str));
                }
            } catch (Exception e) {
                StatisticsManager.getInstance().logException(ae.a(), e);
            } catch (Throwable th) {
                Class cls = ay.class;
            }
        }
    }

    public static void b(Context context) {
        try {
            if (c(context)) {
                bb.a(context, "domain_fail", Integer.valueOf(((Integer) bb.b(context, "domain_fail", Integer.valueOf(0))).intValue() + 1));
            }
        } catch (Exception e) {
            StatisticsManager.getInstance().logException(ae.a(), e);
        }
    }

    public static boolean c(Context context) {
        try {
            if (!TextUtils.equals(am.a(context), "https://api.unmdabd.u178881507.com")) {
                return true;
            }
        } catch (Exception e) {
            StatisticsManager.getInstance().logException(ae.a(), e);
        }
        return false;
    }
}
